'\" t
.TH "SD_EVENT_SOURCE_SET_FLOATING" "3" "" "systemd 249" "sd_event_source_set_floating"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_event_source_set_floating, sd_event_source_get_floating \- Set or retrieve \*(Aqfloating\*(Aq state of event sources
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-event\&.h>
.fi
.ft
.HP \w'int\ sd_event_source_set_floating('u
.BI "int sd_event_source_set_floating(sd_event_source\ *" "source" ", int\ " "floating" ");"
.HP \w'int\ sd_event_source_get_floating('u
.BI "int sd_event_source_get_floating(sd_event_source\ *" "source" ");"
.SH "DESCRIPTION"
.PP
\fBsd_event_source_set_floating()\fR
takes a boolean and sets the \*(Aqfloating\*(Aq state of the specified event source object\&. This is used to change the direction of reference counts for the object and the event loop it is associated with\&. In non\-floating mode, the event source object holds a reference to the event loop object, but not vice versa\&. The creator of the event source object must hold a reference to it as long as the source should exist\&. In floating mode, the event loop holds a reference to the source object, and will decrease the reference count when being freed\&. This means that a reference to the event loop should be held to prevent both from being destroyed\&.
.PP
Various calls that allocate event source objects (i\&.e\&.
\fBsd_event_add_io\fR(3),
\fBsd_event_add_time\fR(3)
and similar) will automatically set an event source object to \*(Aqfloating\*(Aq mode if the caller passed
\fBNULL\fR
in the parameter used to return a reference to the event source object\&. Nevertheless, it may be necessary to gain temporary access to the source object, for example to adjust event source properties after allocation (e\&.g\&. its priority or description string)\&. In those cases the object may be created in non\-floating mode, and the returned reference used to adjust the properties, and the object marked as floating afterwards, and the reference in the caller dropped\&.
.PP
\fBsd_event_source_get_floating()\fR
may be used to query the current \*(Aqfloating\*(Aq state of the event source object
\fIsource\fR\&. It returns zero if \*(Aqfloating\*(Aq mode is off, positive if it is on\&.
.SH "RETURN VALUE"
.PP
On success,
\fBsd_event_source_set_floating()\fR
and
\fBsd_event_source_get_floating()\fR
return a non\-negative integer\&. On failure, they return a negative errno\-style error code\&.
.SS "Errors"
.PP
Returned errors may indicate the following problems:
.PP
\fB\-EINVAL\fR
.RS 4
\fIsource\fR
is not a valid pointer to an
sd_event_source
object\&.
.RE
.PP
\fB\-ECHILD\fR
.RS 4
The event loop has been created in a different process\&.
.RE
.SH "NOTES"
.PP
These APIs are implemented as a shared library, which can be compiled and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.SH "SEE ALSO"
.PP
\fBsd-event\fR(3),
\fBsd_event_add_io\fR(3),
\fBsd_event_add_time\fR(3),
\fBsd_event_add_signal\fR(3),
\fBsd_event_add_child\fR(3),
\fBsd_event_add_inotify\fR(3),
\fBsd_event_add_defer\fR(3),
\fBsd_event_source_set_description\fR(3),
\fBsd_event_source_set_priority\fR(3)
